//
//  EntitySprite.h
//  airfight
//
//  Created by aaron more on 12-8-28.
//  Copyright (c) 2012年 moonriver. All rights reserved.
//

#ifndef airfight_EntitySprite_h
#define airfight_EntitySprite_h

#include "cocos2d.h"
#include "Box2D.h"
#include "extensions/CCNotificationCenter/CCNotificationCenter.h"
#include "env.h"

USING_NS_CC;
USING_NS_CC_EXT;

enum ENTITY_TYPE 
{
    PLAYER_FIGHTER = 0,
    PLAYER_BULLET,
    ENEMY_FIGHTER,
    ENEMY_BULLET,
    BONUS
};

class EntitySprite : public CCSprite
{
    CC_SYNTHESIZE(int,m_pTag,Tag); //tag
    CC_SYNTHESIZE(int,m_pToDestroyFlag,ToDestroyFlag); //销毁标志
public:
    EntitySprite();
    virtual ~EntitySprite();
    virtual bool init();
    virtual void onEnter();
    
    CC_SYNTHESIZE(ENTITY_TYPE,m_EntityType,EntityType);
    void setPhysicsBody(b2Body *body);
    b2Body* getPhysicsBody();
    virtual bool isDirty();
    
    virtual void handleContact(ENTITY_TYPE type, CCDictionary *effect);
    
private:
    b2Body* m_pBody;    // strong ref
};

// for the subclass of CCLayer, each has to implement the static "create" method 
#define SPRITE_CREATE_FUNC(sprite) \
static sprite* create() \
{ \
sprite *pRet = new sprite(); \
if (pRet && pRet->init()) \
{ \
pRet->autorelease(); \
return pRet; \
} \
else \
{ \
delete pRet; \
pRet = NULL; \
return NULL; \
} \
}

#endif
